home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SAT 2.3b4 / Demo ƒ / myPlatform demo ƒ / myPlatform.p < prev    next >
Text File  |  1995-04-23  |  3KB  |  96 lines

  1. {***************************}
  2. {********* myPlatform **********}
  3. {***************************}
  4.  
  5. {This demo is a hack I made, testing if we can use faceless sprites to make stationary}
  6. {obstacles. That worked pretty nicely, so I went on and made some moving platforms too.}
  7. {Take it for what it is: a test hack that suggests one way to make this kind of games.}
  8. {There are many other ways. The controls can be improved a lot, but it is a start.}
  9.  
  10. program myPlatform;
  11.  
  12.     uses
  13. {$ifc UNDEFINED THINK_PASCAL}
  14.         Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit, Traps,{}
  15.         Memory, SegLoad, Scrap, ToolUtils, OSUtils, Menus, Resources, StandardFile,{}
  16.         GestaltEqu, Files, Errors, 
  17. {$endc}
  18.         SAT, sPlayerSprite, sPlatform, sMovPlatForm, sHMovPlatForm;
  19.  
  20.     var
  21.         ignoreSp: SpritePtr;
  22.         l: Longint;
  23.         p: Point;
  24.         r: Rect;
  25.         thepat: SATPatHandle;
  26.  
  27.     procedure DrawInfo;
  28.         var
  29.             r: Rect;
  30.     begin
  31.         SATSetPortBackScreen;
  32.         SetRect(r, 100, 50, 300, 100);
  33.         EraseRect(r);
  34.         FrameRect(r);
  35.         MoveTo(110, 70);
  36.         DrawString('SAT Platform demo');
  37.         MoveTo(110, 90);
  38.         DrawString('Move with "," "." and space');
  39.         SATBackChanged(r);
  40.     end;
  41.  
  42. begin
  43. {Standard Inits are done by Think Pascal.}
  44. {$IFC UNDEFINED THINK_PASCAL}
  45.     SATInitToolbox;
  46. {$ENDC}
  47.  
  48.     SATConfigure(true, kLayerSort, kBackwardCollision, 32);
  49.     SATInit(0, 0, 512, 322); {No PICTs}
  50.  
  51. {Use a background pattern (instead of PICTs - just to demo that too)}
  52.     SATSetPortBackScreen;
  53.     thepat := SATGetPat(128);
  54.     SATPenPat(thepat);
  55.     SetRect(r, 0, 0, gSAT.offsizeH, gSAT.offsizeV);
  56.     PaintRect(r);
  57.  
  58.     CopyBits(gSAT.backScreen.port^.portBits, gSAT.offScreen.port^.portBits, gSAT.offScreen.port^.portrect, gSAT.offscreen.port^.portrect, srcCopy, nil);
  59.  
  60. {Draw the info text}
  61.     DrawInfo;
  62.  
  63. {Initialize all sprite units}
  64.     InitPlayerSprite;
  65.     InitPlatform;
  66.     InitMovPlatform;
  67.     InitHMovPlatform;
  68.  
  69. {Update the game window (gSAT.wind) once more, so the pattern and what we drawn in DrawInfo are shown.}
  70.     SATRedraw;
  71.  
  72. {Make the sprites.}
  73.     GetMouse(p);
  74.     ignoreSp := SATNewSprite(1, p.h, p.v, @SetupPlayerSprite);
  75.     ignoreSp := SATNewSprite(0, 50, 300, @SetupPlatform);
  76.     ignoreSp := SATNewSprite(0, 150, 200, @SetupPlatform);
  77.     ignoreSp := SATNewSprite(0, 250, 100, @SetupPlatform);
  78.     ignoreSp := SATNewSprite(0, 350, 50, @SetupPlatform);
  79.  
  80.     ignoreSp := SATNewSprite(0, 350, 300, @SetupMovPlatform);
  81.     ignoreSp := SATNewSprite(0, 50, 200, @SetupMovPlatform);
  82.  
  83.     ignoreSp := SATNewSprite(0, 200, 150, @SetupHMovPlatform);
  84.  
  85.     HideCursor;
  86.     done := false;
  87.     repeat
  88.         l := TickCount;
  89.         SATRun(true); {Run one frame of animation.}
  90.         while l > TickCount - 2 do {Maximize speed to 30 fps}
  91.             ;
  92.     until done or Button;
  93.     ShowCursor;
  94.     SATSetPortScreen; {To make sure the device is valid when exiting}
  95.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  96. end.